package bueu.bexl;

import static bueu.bexl.utils.TypeUtils.numberValue;

public class MinusExpr extends BexlExpr {

	private final BexlExpr expr;
	
	public MinusExpr(final BexlExpr expr) {
		super(expr.isRelative());
		this.expr = expr;
	}

	@Override
	protected final Object eval(final BexlCtx ctx, final Object current, final boolean set,
			final Object newValue) throws BexlException {
		return -numberValue(this.expr.eval(ctx, current, set, newValue));
	}
	
	@Override
	public final String toString() {
		return "-(" + this.expr + ")";
	}
}
